
const DBUtil = require('../dbUtil')

function list(callback) {

    const sql = "SELECT * FROM foods.user u "
        + " inner join role r"
        + " on r.role_id = u.role_id";

     DBUtil.query(sql, null, function (err, results) {

        results = results.map(function (item) {
            return {
                user_id: item.user_id,
                useranme: item.useranme,
                password: item.password,
                role: {
                    role_id: item.role_id,
                    role_name: item.role_name
                }
            }
        })
        callback(results);
    });
}

module.exports = {
    list
}
